.class Lcom/permission/runtime/j;
.super Lcom/permission/runtime/i;
.source "PopupWriteSettingsRequest.java"


# instance fields
.field private d:Landroid/app/Activity;

.field private e:I
    .annotation build Landroidx/annotation/StringRes;
    .end annotation
.end field

.field private f:Landroid/app/AlertDialog;

.field private g:Lcom/permission/runtime/b;


# direct methods
.method protected constructor <init>(Landroid/app/Activity;)V
    .locals 1

    .line 1
    invoke-direct {p0}, Lcom/permission/runtime/i;-><init>()V

    .line 2
    sget-object v0, Lcom/permission/runtime/b;->a:Lcom/permission/runtime/b;

    iput-object v0, p0, Lcom/permission/runtime/j;->g:Lcom/permission/runtime/b;

    .line 3
    iput-object p1, p0, Lcom/permission/runtime/j;->d:Landroid/app/Activity;

    return-void
.end method

.method static synthetic a(Lcom/permission/runtime/j;)Landroid/app/AlertDialog;
    .locals 0

    .line 1
    iget-object p0, p0, Lcom/permission/runtime/j;->f:Landroid/app/AlertDialog;

    return-object p0
.end method

.method static synthetic b(Lcom/permission/runtime/j;)V
    .locals 0

    .line 1
    invoke-direct {p0}, Lcom/permission/runtime/j;->d()V

    return-void
.end method

.method private d()V
    .locals 2

    .line 1
    sget v0, Landroid/os/Build$VERSION;->SDK_INT:I

    const/16 v1, 0x17

    if-lt v0, v1, :cond_1

    .line 2
    iget-object v0, p0, Lcom/permission/runtime/j;->g:Lcom/permission/runtime/b;

    if-eqz v0, :cond_1

    .line 3
    iget-object v0, p0, Lcom/permission/runtime/j;->d:Landroid/app/Activity;

    invoke-static {v0}, Landroid/provider/Settings$System;->canWrite(Landroid/content/Context;)Z

    move-result v0

    if-eqz v0, :cond_0

    .line 4
    iget-object v0, p0, Lcom/permission/runtime/j;->g:Lcom/permission/runtime/b;

    const/4 v1, 0x1

    invoke-virtual {v0, v1}, Lcom/permission/runtime/b;->a(Z)V

    goto :goto_0

    .line 5
    :cond_0
    iget-object v0, p0, Lcom/permission/runtime/j;->g:Lcom/permission/runtime/b;

    const/4 v1, 0x0

    invoke-virtual {v0, v1}, Lcom/permission/runtime/b;->a(Z)V

    :goto_0
    const/4 v0, 0x0

    .line 6
    iput-object v0, p0, Lcom/permission/runtime/j;->g:Lcom/permission/runtime/b;

    :cond_1
    return-void
.end method

.method private e()V
    .locals 6

    .line 1
    iget-object v0, p0, Lcom/permission/runtime/j;->f:Landroid/app/AlertDialog;

    const/4 v1, 0x0

    if-nez v0, :cond_1

    .line 2
    sget v0, Landroid/os/Build$VERSION;->SDK_INT:I

    const/16 v2, 0x15

    if-lt v0, v2, :cond_0

    .line 3
    new-instance v0, Landroid/app/AlertDialog$Builder;

    iget-object v2, p0, Lcom/permission/runtime/j;->d:Landroid/app/Activity;

    const v3, 0x103000f

    invoke-direct {v0, v2, v3}, Landroid/app/AlertDialog$Builder;-><init>(Landroid/content/Context;I)V

    goto :goto_0

    .line 4
    :cond_0
    new-instance v0, Landroid/app/AlertDialog$Builder;

    iget-object v2, p0, Lcom/permission/runtime/j;->d:Landroid/app/Activity;

    invoke-direct {v0, v2}, Landroid/app/AlertDialog$Builder;-><init>(Landroid/content/Context;)V

    .line 5
    :goto_0
    iget-object v2, p0, Lcom/permission/runtime/j;->d:Landroid/app/Activity;

    invoke-static {v2}, Landroid/view/LayoutInflater;->from(Landroid/content/Context;)Landroid/view/LayoutInflater;

    move-result-object v2

    sget v3, Lcom/permission/runtime/m;->dialog_special_permission_ask_rarionale:I

    const/4 v4, 0x0

    invoke-virtual {v2, v3, v4}, Landroid/view/LayoutInflater;->inflate(ILandroid/view/ViewGroup;)Landroid/view/View;

    move-result-object v2

    .line 6
    sget v3, Lcom/permission/runtime/l;->dialog_content:I

    invoke-virtual {v2, v3}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v3

    check-cast v3, Landroid/widget/TextView;

    iget-object v4, p0, Lcom/permission/runtime/j;->d:Landroid/app/Activity;

    iget v5, p0, Lcom/permission/runtime/j;->e:I

    invoke-virtual {v4, v5}, Landroid/app/Activity;->getString(I)Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v3, v4}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    .line 7
    invoke-virtual {v0}, Landroid/app/AlertDialog$Builder;->create()Landroid/app/AlertDialog;

    move-result-object v0

    iput-object v0, p0, Lcom/permission/runtime/j;->f:Landroid/app/AlertDialog;

    .line 8
    invoke-virtual {v0, v1}, Landroid/app/AlertDialog;->setCancelable(Z)V

    .line 9
    iget-object v0, p0, Lcom/permission/runtime/j;->f:Landroid/app/AlertDialog;

    invoke-virtual {v0}, Landroid/app/AlertDialog;->show()V

    .line 10
    iget-object v0, p0, Lcom/permission/runtime/j;->f:Landroid/app/AlertDialog;

    invoke-virtual {v0}, Landroid/app/AlertDialog;->getWindow()Landroid/view/Window;

    move-result-object v0

    invoke-virtual {v0, v2}, Landroid/view/Window;->setContentView(Landroid/view/View;)V

    .line 11
    sget v0, Lcom/permission/runtime/l;->txt_grant:I

    invoke-virtual {v2, v0}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v0

    new-instance v1, Lcom/permission/runtime/j$a;

    invoke-direct {v1, p0}, Lcom/permission/runtime/j$a;-><init>(Lcom/permission/runtime/j;)V

    invoke-virtual {v0, v1}, Landroid/view/View;->setOnClickListener(Landroid/view/View$OnClickListener;)V

    .line 12
    sget v0, Lcom/permission/runtime/l;->txt_cancel:I

    invoke-virtual {v2, v0}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v0

    new-instance v1, Lcom/permission/runtime/j$b;

    invoke-direct {v1, p0}, Lcom/permission/runtime/j$b;-><init>(Lcom/permission/runtime/j;)V

    invoke-virtual {v0, v1}, Landroid/view/View;->setOnClickListener(Landroid/view/View$OnClickListener;)V

    goto :goto_1

    .line 13
    :cond_1
    invoke-virtual {v0, v1}, Landroid/app/AlertDialog;->setCancelable(Z)V

    .line 14
    iget-object v0, p0, Lcom/permission/runtime/j;->f:Landroid/app/AlertDialog;

    invoke-virtual {v0}, Landroid/app/AlertDialog;->show()V

    :goto_1
    return-void
.end method


# virtual methods
.method public a()V
    .locals 2

    .line 5
    iget-object v0, p0, Lcom/permission/runtime/j;->f:Landroid/app/AlertDialog;

    const/4 v1, 0x0

    if-eqz v0, :cond_0

    .line 6
    invoke-virtual {v0}, Landroid/app/AlertDialog;->dismiss()V

    .line 7
    iput-object v1, p0, Lcom/permission/runtime/j;->f:Landroid/app/AlertDialog;

    .line 8
    :cond_0
    iget-object v0, p0, Lcom/permission/runtime/j;->g:Lcom/permission/runtime/b;

    if-eqz v0, :cond_1

    .line 9
    iput-object v1, p0, Lcom/permission/runtime/j;->g:Lcom/permission/runtime/b;

    :cond_1
    return-void
.end method

.method public a(I)V
    .locals 0
    .param p1    # I
        .annotation build Landroidx/annotation/StringRes;
        .end annotation
    .end param

    if-nez p1, :cond_0

    .line 2
    sget p1, Lcom/permission/runtime/n;->write_setting_permissions_msg:I

    .line 3
    :cond_0
    iput p1, p0, Lcom/permission/runtime/j;->e:I

    return-void
.end method

.method public a(Lcom/permission/runtime/b;)V
    .locals 0

    .line 4
    iput-object p1, p0, Lcom/permission/runtime/j;->g:Lcom/permission/runtime/b;

    return-void
.end method

.method public a(IILandroid/content/Intent;)Z
    .locals 0

    .line 10
    iget p2, p0, Lcom/permission/runtime/i;->b:I

    if-ne p1, p2, :cond_0

    .line 11
    invoke-direct {p0}, Lcom/permission/runtime/j;->d()V

    const/4 p1, 0x1

    return p1

    :cond_0
    const/4 p1, 0x0

    return p1
.end method

.method public b()V
    .locals 2

    .line 2
    iget-object v0, p0, Lcom/permission/runtime/j;->d:Landroid/app/Activity;

    invoke-static {v0}, Lcom/permission/runtime/f;->c(Landroid/content/Context;)Z

    move-result v0

    if-nez v0, :cond_0

    .line 3
    invoke-direct {p0}, Lcom/permission/runtime/j;->e()V

    goto :goto_0

    .line 4
    :cond_0
    iget-object v0, p0, Lcom/permission/runtime/j;->g:Lcom/permission/runtime/b;

    const/4 v1, 0x1

    invoke-virtual {v0, v1}, Lcom/permission/runtime/b;->a(Z)V

    :goto_0
    return-void
.end method

.method public c()V
    .locals 3
    .annotation build Landroid/annotation/TargetApi;
        value = 0x17
    .end annotation

    .line 1
    sget v0, Landroid/os/Build$VERSION;->SDK_INT:I

    const/16 v1, 0x17

    if-lt v0, v1, :cond_0

    .line 2
    iget-object v0, p0, Lcom/permission/runtime/j;->d:Landroid/app/Activity;

    invoke-static {v0}, Landroid/provider/Settings$System;->canWrite(Landroid/content/Context;)Z

    move-result v0

    if-nez v0, :cond_0

    .line 3
    :try_start_0
    new-instance v0, Landroid/content/Intent;

    const-string v1, "android.settings.action.MANAGE_WRITE_SETTINGS"

    invoke-direct {v0, v1}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    .line 4
    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "package:"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    iget-object v2, p0, Lcom/permission/runtime/j;->d:Landroid/app/Activity;

    invoke-virtual {v2}, Landroid/app/Activity;->getPackageName()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v1}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v1

    invoke-virtual {v0, v1}, Landroid/content/Intent;->setData(Landroid/net/Uri;)Landroid/content/Intent;

    .line 5
    iget-object v1, p0, Lcom/permission/runtime/j;->d:Landroid/app/Activity;

    iget v2, p0, Lcom/permission/runtime/i;->b:I

    invoke-virtual {v1, v0, v2}, Landroid/app/Activity;->startActivityForResult(Landroid/content/Intent;I)V
    :try_end_0
    .catch Landroid/content/ActivityNotFoundException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    :catch_0
    move-exception v0

    .line 6
    invoke-virtual {v0}, Landroid/content/ActivityNotFoundException;->printStackTrace()V

    :cond_0
    :goto_0
    return-void
.end method
